package com.ruoyi.workstation.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.workstation.domain.UserFirmwarePackage;
import com.ruoyi.workstation.service.IUserFirmwarePackageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户固件包管理Controller
 * 
 * @author ruoyi
 * @date 2024-01-13
 */
@Controller
@RequestMapping("/workstation/userfirmwarepackage")
public class UserFirmwarePackageController extends BaseController
{
    private String prefix = "workstation/userfirmwarepackage";

    @Autowired
    private IUserFirmwarePackageService userFirmwarePackageService;

    @RequiresPermissions("workstation:userfirmwarepackage:view")
    @GetMapping()
    public String userfirmwarepackage()
    {
        return prefix + "/userfirmwarepackage";
    }

    /**
     * 查询客户固件包管理列表
     */
    @RequiresPermissions("workstation:userfirmwarepackage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(UserFirmwarePackage userFirmwarePackage)
    {
        startPage();
        List<UserFirmwarePackage> list = userFirmwarePackageService.selectUserFirmwarePackageList(userFirmwarePackage);
        return getDataTable(list);
    }

    /**
     * 导出客户固件包管理列表
     */
    @RequiresPermissions("workstation:userfirmwarepackage:export")
    @Log(title = "客户固件包管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(UserFirmwarePackage userFirmwarePackage)
    {
        List<UserFirmwarePackage> list = userFirmwarePackageService.selectUserFirmwarePackageList(userFirmwarePackage);
        ExcelUtil<UserFirmwarePackage> util = new ExcelUtil<UserFirmwarePackage>(UserFirmwarePackage.class);
        return util.exportExcel(list, "客户固件包管理数据");
    }

    /**
     * 新增客户固件包管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存客户固件包管理
     */
    @RequiresPermissions("workstation:userfirmwarepackage:add")
    @Log(title = "客户固件包管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(UserFirmwarePackage userFirmwarePackage)
    {
        return toAjax(userFirmwarePackageService.insertUserFirmwarePackage(userFirmwarePackage));
    }

    /**
     * 修改客户固件包管理
     */
    @RequiresPermissions("workstation:userfirmwarepackage:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        UserFirmwarePackage userFirmwarePackage = userFirmwarePackageService.selectUserFirmwarePackageById(id);
        mmap.put("userFirmwarePackage", userFirmwarePackage);
        return prefix + "/edit";
    }

    /**
     * 修改保存客户固件包管理
     */
    @RequiresPermissions("workstation:userfirmwarepackage:edit")
    @Log(title = "客户固件包管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(UserFirmwarePackage userFirmwarePackage)
    {
        return toAjax(userFirmwarePackageService.updateUserFirmwarePackage(userFirmwarePackage));
    }

    /**
     * 删除客户固件包管理
     */
    @RequiresPermissions("workstation:userfirmwarepackage:remove")
    @Log(title = "客户固件包管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(userFirmwarePackageService.deleteUserFirmwarePackageByIds(ids));
    }
}
